package com.example.su_shi_tan_home.fun_config

import com.example.su_shi_tan_core.arouter.HomeARouter
import com.example.su_shi_tan_core.arouter.MineARouter
import com.example.su_shi_tan_core.arouter.SignInARouter
import com.example.su_shi_tan_core.constant.SignUserBeanHolder
import com.example.su_shi_tan_core.db.LogInTokenManager
import com.example.su_shi_tan_core.db.UserInfoBean
import com.example.su_shi_tan_core.db.UserInfoBeanHolder
import com.example.su_shi_tan_home.R
import com.example.su_shi_tan_home.bean.HomeListBean
import com.example.su_shi_tan_home.bean.TanFanBean

const val ACTIVE = "active"

fun funConfigArray(): List<FunConfig> {

    return listOf(
        FunConfig(
            R.mipmap.home_fu_li,
            R.string.home_fu_li,
            ""
        ),
        FunConfig(
            R.mipmap.home_contract,
            R.string.home_contract,
            ""
        ),
        FunConfig(
            R.mipmap.home_new_sales,
            R.string.home_new_sales,
            ""
        ),

        //home_lighting_true
        FunConfig(
            if (SignUserBeanHolder.getSignUser()?.is_day_sgin == true)
                R.mipmap.home_lighting_true
            else
                R.mipmap.home_lighting,

            R.string.home_lighting,
            ACTIVE,
            SignUserBeanHolder.getSignUser()?.is_day_sgin ?: false
        )

    )
}


fun tanFanList() = if (!LogInTokenManager.tokenManager.haveSignedIn())

    listOf(
        TanFanBean(
            "未登录",
            true,
            SignInARouter.SignInFragment,
            "去登录"
        ),
    )
else
    listOf(
        TanFanBean(
            "实名",
//             UserInfoBeanHolder.getUserInfoBean()?.verifyStrFlag() == UserInfoBean.unSubmit,
            verifyStrFlag(),
            MineARouter.IDENTIFY_VERIFY,
            verifyStrFlagStr()
        ),
        TanFanBean(
            "收款",
            UserInfoBeanHolder.getUserInfoBean()?.isCollection() == false,
            isCollection()
//            MineARouter.ADD_PAYING_WAY
        ),
        TanFanBean(
            "收货",
            UserInfoBeanHolder.getUserInfoBean()?.isAddress() == false,
            addressPath()
//            MineARouter.ADD_DELIVERY_INFO
        ),
        TanFanBean(
            "激活",
            UserInfoBeanHolder.getUserInfoBean()?.isActivation() == false,
            HomeARouter.LIGHTING,
        )
    )

fun isCollection(): String {
    return  if (UserInfoBeanHolder.getUserInfoBean()?.isCollection() == false)
        MineARouter.ADD_PAYING_WAY
    else
        MineARouter.PAYING_WAY_LIST
}

fun addressPath(): String {
     return if (UserInfoBeanHolder.getUserInfoBean()?.isAddress()==false)
         MineARouter.ADD_DELIVERY_INFO
    else
         MineARouter.ADD_DELIVERY_INFO_HISTORY
}

fun verifyStrFlagStr(): String {
   return when (UserInfoBeanHolder.getUserInfoBean()?.verifyStrFlag()) {
        UserInfoBean.checkedYes -> "已完成"
        UserInfoBean.unSubmit -> "去完成"
        UserInfoBean.checking -> "审核中"
        UserInfoBean.checkedNot -> "未通过"
        else -> "去完成"
    }
}

fun verifyStrFlag(): Boolean {
    return UserInfoBeanHolder.getUserInfoBean()?.verifyStrFlag() != UserInfoBean.checkedYes
}


fun homeListBeanList() = listOf(
    HomeListBean(
        "当前注册堂粉",
        "${SignUserBeanHolder.getSignUser()?.reg_count ?: 0}",
        "名"
    ),
    HomeListBean(
        "已激活堂粉",
        "${SignUserBeanHolder.getSignUser()?.total_activation_count ?: 0}",
        "名"
    ),
    HomeListBean(
        "已送出资产",
        "${SignUserBeanHolder.getSignUser()?.total_st_balance ?: 0}",
        "ST"
    )
)